import { storage } from '@/utils/storage'
/*
 * @Author: CQJ
 * @Date: 2022-08-25 20:00:27
 * @LastEditors: CQJ
 * @LastEditTime: 2022-09-02 22:01:16
 * @Description:
 */
import { reactive } from 'vue'
type Key = string
interface IFilmListState {
  status: undefined
  categ_id: string | undefined // 全部分类
  subcateg_id: string | undefined // 子分类
  area_id: string | undefined //地区
  video_year: string | undefined //年代
  video_lang: string | undefined //语言
  publish_state: number | undefined //发布状态 1-已完结 2-连载
  play_url_state: number | undefined //有无播放地址 1-有地址 2-无地址
  video_id: string | undefined // 影片id
  video_keyword: string | undefined // 影片关键词
  site_id: string | undefined
  sort?: string | undefined
  order?: number | undefined
  price_type: number | undefined
}

// 状态管理
export const filmListState = reactive<IFilmListState>({
  status: undefined,
  categ_id: undefined,
  subcateg_id: undefined,
  area_id: undefined,
  video_year: undefined,
  video_lang: undefined,
  publish_state: undefined, //发布状态 1-已完结 2-连载
  play_url_state: undefined, //有无播放地址 1-有地址 2-无地址
  video_id: undefined,
  video_keyword: undefined,
  price_type: undefined,
  site_id: undefined,
  sort: undefined,
  order: undefined
})
// 状态管理
export const statusState = reactive<{ selectedRowKeys: string[] }>({
  selectedRowKeys: []
})
export const resetState = () => {
  let key: keyof IFilmListState
  for (key in filmListState) {
    filmListState[key] = undefined
  }
  filmListState.site_id = storage.get('siteId')
}
